package com.guldan.thrall.web.controller;

import com.guldan.core.dubbo.client.ResponseDTO;
import com.guldan.core.response.ResponseJson;
import com.guldan.jaina.dto.progress.BarDTO;
import com.guldan.jaina.provider.IUploadProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;

/**
 * Created by Silas.
 * Date: 2016/12/31
 * Time: 17:26
 */
@Controller
@RequestMapping("/upload")
public class UploadController {

    @Autowired
    private IUploadProvider iUploadProvider;

    @RequestMapping(value = "/getBarInfo", method = RequestMethod.POST)
    @ResponseJson
    public BarDTO getBarInfo(@RequestBody BarDTO barDTO) throws Exception {

        ResponseDTO<BarDTO> responseDTO = iUploadProvider.getBarDTO(barDTO.getBarId(), barDTO.getTypeId());
        if (responseDTO.isSuccess())
            return responseDTO.getData();
        else {
            throw responseDTO.getException();
        }
    }




}
